<?php
    if($accounts->num_rows()>0){
        $account=$accounts->row();
        $date_patern = '%d/%m/%Y';
        $incrit = mdate($date_patern,$account->birthday);
        $gender = '';
        if($account->sex == TRUE){
            $gender = 'Male';
        }else{
            $gender = 'Female';
        }
    }
    $account_id = $this->session->userdata('doogy.id');
    $id = $account->account_id;

    $selected_album=array(
    'table_name'=>'doggy_albums',
    'key_field' => 'id',
    'value_field' => 'title',
    'where'=>array('account_id'=>$account_id),
    'init_data'=>array('key'=>'','name'=>'Select album'),
    );
    $title_album=isset($title_album)?$title_album:"";
?>

<div id="acc_details">
    <div align="left" id="title_view_profile" ><?php echo $account->display_name;?>
        <?php if($account_id!=$id) {?>
            <span class="title_view_profile_img"><a href="<?php echo site_url('message/send/'.$account->account_id)?>"><img border="0" src="<?php echo base_url().'assets/css/'?>images/write_message.png"/></a></span>
                <span class="title_view_profile_right">
            <?php }?>
                <span style="float: right;"><a href="<?php echo site_url('home/compte/'.$account->account_id)?>">Profile</a> | <a href="<?php echo site_url('home/wall_friend/'.$account->account_id)?>">Mur</a> | 
                <?php if($account_id!=$id) {?>
                    <a href="<?php echo site_url('home/galery_friend/'.$account->account_id)?>">Galerie</a>
                <?php } else {?>
                    <a href="<?php echo site_url('image/my_galary/')?>">Galerie</a>
                <?php } ?>
                 </span>
    </div> 
    <div class="recent_img">
        <div id="post_wall" style="padding-top: 8px;padding-bottom:10px">
        <?php if(is_friend($account_id, $account->account_id)):?>
       <a id="link2" class="active" href="#">DE QUOI VOUS-PENSEZ ?</a> &nbsp;<a id="link1" href="#" >ENVOYER PHOTO</a>
            <div id="photo_upload" style="display: none;">
                <?php 
                    $attributes = array('class' => 'upload_image', 'id' => 'upload_image');
                    echo form_open_multipart('image/upload_image', $attributes);
                ?>
                <table align="center">
                    <tr>
                        <td><label for="image_upload">Photo : </label></td>
                        <td><input type="file" name="userfile" size="20" /></td>
                    </tr>
                    <tr>
                        <td><label for="image_title">Nom de la photo :</label></td>
                        <td><input type="text" name="image_title" id="image_title" size="35"/></td>
                    </tr>
                    <tr>
                        <td><label for="image_title">Album :</label></td>
                        <td><?php echo form_dropdown('album',dropdown_data($selected_album),'style="width:150px;"')?></td>
                    </tr>

                    <tr>
                        <td></td> <td colspan="2"><input type="submit" name="submit_upload_image" id="submit_upload_image" value="Partager"/></td>
                    </tr>
                </table>
                </form>
            </div>
            <div class="wall_sms">
                <?php echo form_open('message/send_wall_message_friend'.'/'.$account->account_id); ?>
                <table>
                    <tr><td> <textarea name="wall_message" style="overflow:visible;" cols="45" rows="1"></textarea></td>
                        <td> <input type="submit" name="submit" value="Partager"/></td></tr>
                </table>
                <?php echo form_error('wall_message')?>
                <?php echo form_close(); ?>
            </div>
         </div>

            <?php foreach ($own_walls as $own_wall) :?>
                <?php
                    $post_date = $own_wall['posted_time'];
                    $now = time();
                    $time_posted_calculate = timespan($post_date, $now);
                ?>
                <?php
                    $image_ava = './doggy_avatar/images/' . $own_wall['avatar'];
                    if(file_exists($image_ava) && $own_wall['avatar'] != null){
                        $image_ava = base_url() . 'doggy_avatar/images/' . $own_wall['avatar'];
                    } else{
                        $image_ava = root_url('doggy-flirt') .'./assets/noimage.gif';
                }?>
                    <table width="480px" class="list">
                        <tr>
                            <td width="10%" valign="top"><a href="#"><img src="<?php echo $image_ava;?>" width="50" border="0"></a></td>
                            <td align="left" valign="top">
                                <a href="#" class="account_link"><?php echo  $own_wall['display_name'];?></a>
                                <?php if($id==$this->_data['account_id']){?>
                                    <a href="<?php echo site_url('home/delete_wall_message'.'/'.$own_wall['id'].'/'.$id)?>" onclick="return confirm ('Vous êtes sûr?')"><img align="right" alt="" src="<?php echo base_url().'assets/css/images/delete.png';?>" border="0" /></a>
                                    <?php }?>
                                <p style="color: #886525;"><?php echo $own_wall['content'];?></p>
                                <?php if($own_wall['image']!=NULL){?>
                                    <a id="example5" href="<?php echo base_url().'upload_photo/'.$own_wall['image'];?>" title="">
                                        <img alt="" src="<?php echo base_url().'upload_photo/thumbs/'.$own_wall['image'];?>" width="121px" border="0" />
                                    </a>
                                    <?php }?>
                                <p style="color: blue;">Il y a <?php echo $time_posted_calculate;?></p>
                            </td>
                        </tr>
                    </table>

                <?php endforeach;?>
            <?php endif;?>
        <div align="center"><font color="#5d94c5" style="font-size: normal;"><?php echo $pagination;?></font></div>

    </div>
</div>